﻿using System;
using System.Collections.Generic;
using Epitech.Krisk.Kinect.Sensor.Tools;
using Microsoft.Research.Kinect.Nui;

namespace Epitech.Krisk.Kinect.Sensor.Gestures
{
    public enum GestureType
    {
        SwipeToleft,
        SwipeToRight,
        SwipeToTop,
        SwipeToBottom
    };

    public abstract class GestureDetector
    {
        public int MinimalPeriodBetweenGesture { get; set; }

        protected DateTime _lastMove = DateTime.Now;
        protected const int TimeBetweenMovement = 2; //Seconds

        private readonly List<Entry> _entries = new List<Entry>();
        protected List<Entry> Entries
        {
            get { return _entries; }
        }

        private readonly int _numberOfGestureAnalyzed;
        public int NumberOfGestureAnalyzed
        {
            get { return _numberOfGestureAnalyzed; }
        }

        protected GestureDetector(int numberOfGestureAnalyzed = 20, int minimalPeriodBetweenGesture = 0)
        {
            _numberOfGestureAnalyzed = numberOfGestureAnalyzed;
            MinimalPeriodBetweenGesture = minimalPeriodBetweenGesture;
        }

        public virtual void AddJoint(Vector position, SkeletonEngine engine)
        {
            Entry newEntry = new Entry { Position = position.ToVector3X(), Time = DateTime.Now };
            Entries.Add(newEntry);

            if (Entries.Count > NumberOfGestureAnalyzed)
                Entries.RemoveAt(0);
            LookForGesture();
        }

        protected abstract void LookForGesture();
    }
}